#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QWebEngineView>
#include <QWebEnginePage>
#include <QWebEngineSettings> // Add this line

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    WebView *view = new WebView(this); // Use WebView instead of QWebEngineView
    QWebEnginePage *page = new QWebEnginePage(view);
    view->setPage(page);
    view->setUrl(QUrl("http://10.10.1.81:8081/tour_guide/index.html"));
    setCentralWidget(view);

    // Make the window fullscreen
    showFullScreen();

    // Configure QWebEngineSettings to suppress mixed content warnings
    view->settings()->setAttribute(QWebEngineSettings::AllowRunningInsecureContent, true);

    // Connect urlChanged signal to handle URL changes
    connect(view, &QWebEngineView::urlChanged, this, [view](const QUrl &url) {
        view->setUrl(url);
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}

